package com.hxd.otc.module.convenience.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.base.BaseRecyclerPresenter;
import com.hxd.otc.module.convenience.adapter.PaymentMethodAdapter;
import com.hxd.otc.module.convenience.bean.PaymentMethodBean;
import com.hxd.otc.module.convenience.contract.PaymentMethodContract;
import com.hxd.otc.module.convenience.model.ConvenienceModel;
import com.hxd.otc.net.BaseObserver;

import java.util.ArrayList;

/**
 * Created by lzy on 2018/12/12 0012.
 * description ${支付对话框-支付方式Presenter}
 */
public class PaymentMethodPresenter extends BaseRecyclerPresenter<PaymentMethodContract.IView, PaymentMethodAdapter, PaymentMethodBean> implements PaymentMethodContract.IPresenter {

    private final ConvenienceModel mConvenienceModel;

    public PaymentMethodPresenter(PaymentMethodContract.IView iView) {
        super(iView);
        mConvenienceModel = ConvenienceModel.getInstance();
    }

    @Override
    public void loadData(final boolean isRefresh) {
        mConvenienceModel.getPaymentMethodList(new BaseObserver<ArrayList<PaymentMethodBean>>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull ArrayList<PaymentMethodBean> paymentMethodBeans) {
                onLoadDataSuccess(isRefresh, paymentMethodBeans);
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                onLoadDataFail(isRefresh, errMessage);
            }
        }, mView.<BaseBean<ArrayList<PaymentMethodBean>>>bindAutoDispose());
    }
}
